package 如何初始化数组;

import java.util.Arrays;
import java.util.Scanner;

public class 数组反转12 {
    public static void main(String[] args) {
        System.out.println("请输入随机数组长度:");
        Scanner b=new Scanner(System.in);
        int length=b.nextInt();
        int[] a=new int[length];
        for(int i=0;i<length;i++){
            a[i]=(int)(Math.random()*100);
        }
        System.out.print("原数组数据:");
        //for (int i = 0; i < a.length; i++) {
        //  System.out.print("a" + i + ":" + a[i]+" ");
        //}
        System.out.print(Arrays.toString(a));
        for(int i=0;i<(a.length/2);i++){
            int buff=0;
            buff=a[a.length-i-1];
            a[a.length-i-1]=a[i];
            a[i]=buff;
        }
        System.out.println("");
        System.out.print("翻转后数组:");
        //for (int i = 0; i < a.length; i++) {
        //    System.out.print("a" + i + ":" + a[i]+" ");
        //}
        System.out.print(Arrays.toString(a));
    }
}